package com.bdqn.zhang.dao.impl;

import com.bdqn.zhang.dao.VivoproductDao;
import com.bdqn.zhang.dao.impl.dbutil.DButil;
import com.bdqn.zhang.pojo.Memberinfo;
import com.bdqn.zhang.pojo.Vivoej;
import com.bdqn.zhang.pojo.Vivoproduct;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class VivoproductDaoimpl extends DButil implements VivoproductDao {
    Connection conn = null;
    PreparedStatement ment = null;
    ResultSet resultSet = null;

    @Override
    public List<Vivoproduct> getAll(int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time,yij.imglbt,yij.imgzst from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, from);
            ment.setObject(2, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    vivoej.setImglbt(resultSet.getString(12));
                    vivoej.setImgzst(resultSet.getString(13));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> getAllhsz(int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time,yij.imglbt,yij.imgzst from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, from);
            ment.setObject(2, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    vivoej.setImglbt(resultSet.getString(12));
                    vivoej.setImgzst(resultSet.getString(13));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int getCount() {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1";
        try {
            ment = conn.prepareStatement(sql);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int getCounthsz() {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0";
        try {
            ment = conn.prepareStatement(sql);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int del(String id) {
        String sql = "update Vivo_product SET shanchu=0 where yid in (?)";
        Object[] obj = {id};
        return executeUpdate(sql, obj);
    }

    @Override
    public int delsc(String id) {
        String sql = "delete from Vivo_product where yid in (?)";
        Object[] obj = {id};
        return executeUpdate(sql, obj);
    }

    @Override
    public int delhuifu(String id) {
        String sql = "update Vivo_product SET shanchu=1 where yid in (?)";
        Object[] obj = {id};
        return executeUpdate(sql, obj);
    }

    @Override
    public List<Vivoproduct> getAlls(String name, String rr) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select etype from Vivo_erji where resType=? AND yid=(select v.eid from Vivo_erji as v where v.etype=?)";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, name);
            ment.setObject(2, rr);
            //给参数传值
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoproduct = new Vivoproduct();
                    vivoproduct.setEtype(resultSet.getString(1));
                    list.add(vivoproduct);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> getAllsss(String name) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select etype from Vivo_erji where resType=?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, name);
            //给参数传值
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoproduct = new Vivoproduct();
                    vivoproduct.setEtype(resultSet.getString(1));
                    list.add(vivoproduct);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> getAllys(String name, int rr) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select etype from Vivo_erji where resType=? AND eid=(select a.yid from Vivo_erji as a where a.eid=(SELECT yid from Vivo_product where yid=?))";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, name);
            ment.setObject(2, rr);
            //给参数传值
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoproduct = new Vivoproduct();
                    vivoproduct.setEtype(resultSet.getString(1));
                    list.add(vivoproduct);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int gai(Vivoproduct Vivoproduct) {
        String sql = "UPDATE Vivo_product SET status=? WHERE id=?";
        Object[] obj = {Vivoproduct.getStatus(), Vivoproduct.getId()};
        return executeUpdate(sql, obj);
    }

    @Override
    public int zt(Vivoproduct Vivoproduct) {
        String sql = "INSERT INTO Vivo_product(yid,status,shanchu) VALUES((select v.eid from Vivo_erji as v where v.etype=?),?,?)";
        Object[] obj = {Vivoproduct.getEtype(), Vivoproduct.getStatus(), Vivoproduct.getShanchu()};
        return executeUpdate(sql, obj);
    }

    @Override
    public List<Vivoproduct> retrieveztcx(int name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where status=? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, name);
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrievemhztcx(int name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_product where status=? AND shanchu=0";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, name);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    //    @Override
    public int edits(Vivoproduct Vivoproduct) {
        String sql = "UPDATE Vivo_product yij,Vivo_erji ej SET yij.descs=?,yij.image=?,yij.pv=?,yij.status=?,yij.add_time=?,yij.kc=?,ej.etype=?,ej.img=?,yij.imglbt=?,yij.imgzst=? WHERE yij.yid in(SELECT min_id FROM (SELECT yid AS min_id from Vivo_product where id=?) AS a)AND eid in(SELECT min_id FROM (SELECT yid AS min_id from Vivo_product where id=?) AS a)";
        Object[] obj = {Vivoproduct.getDescs(), Vivoproduct.getImage(), Vivoproduct.getPv(), Vivoproduct.getStatus(), Vivoproduct.getAdd_time(), Vivoproduct.getKc(), Vivoproduct.getEtype(), Vivoproduct.getImg(), Vivoproduct.getImglbt(), Vivoproduct.getImgzst(), Vivoproduct.getId(), Vivoproduct.getId()};
        return executeUpdate(sql, obj);
    }


    @Override
    public int add(Vivoproduct Vivoproduct) {
        String sql = "INSERT INTO Vivo_product(yid,descs,image,pv,status,add_time,kc,imglbt,imgzst,shanchu)VALUES((select v.eid from Vivo_erji as v where v.etype=?),?,?,?,?,?,?,?,?,?)";
        Object[] obj = {Vivoproduct.getEtype(), Vivoproduct.getDescs(), Vivoproduct.getImage(), Vivoproduct.getPv(), Vivoproduct.getStatus(), Vivoproduct.getAdd_time(), Vivoproduct.getKc(), Vivoproduct.getImglbt(), Vivoproduct.getImgzst(), Vivoproduct.getShanchu()};
        return executeUpdate(sql, obj);
    }

    @Override
    public List<Vivoproduct> ztcx(int name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where status=? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, name);
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int mhztcx(int name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_product where status=? AND shanchu=1";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, name);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> dan(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where concat(ej.etype,yij.descs,yij.image,yij.add_time) like ? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int mhdan(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 AND concat(ej.etype,yij.descs,yij.image,yij.add_time) like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> retrieve2dan(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where concat(ej.etype,yij.descs,yij.image,yij.add_time) like ? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrieve2mhdan(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 AND concat(ej.etype,yij.descs,yij.image,yij.add_time) like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int spjgcx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 AND image like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int spdate(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 AND add_time like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int spjscx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 AND descs like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int spmccx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=1 AND etype like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> yhmcx(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where ej.etype like ? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> xbcx(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.descs like ? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> spjg(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.image like ? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> spsjsj(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.add_time like ? AND yij.shanchu=1 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrievespmccx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 AND etype like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> retrieveyhmcx(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where ej.etype like ? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrievespjscx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 AND descs like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> retrievexbcx(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.descs like ? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrievespjgcx(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 AND image like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> retrievespjg(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.image like ? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public int retrievespdate(String name) {
        conn = getConnerction();
        String sql = "select count(1) from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.shanchu=0 AND add_time like ?";
        try {
            ment = conn.prepareStatement(sql);
            ment.setObject(1, "%" + name + "%");
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                if (resultSet.next()) {
                    return resultSet.getInt(1);
                }
            }
            return 0;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }

    @Override
    public List<Vivoproduct> retrievespsjsj(String name, int from, int pageSixe) {
        Connection conn = null;
        PreparedStatement ment = null;
        ResultSet resultSet = null;
        conn = getConnerction();
        List<Vivoproduct> list = new ArrayList();
        String sql = "select yij.id,ej.eid,yij.yid,ej.etype,yij.descs,ej.img,yij.image,yij.pv,yij.kc,yij.status,yij.add_time from Vivo_erji ej inner join  Vivo_product yij on ej.eid=yij.yid where yij.add_time like ? AND yij.shanchu=0 limit ?,?";
        try {
            ment = conn.prepareStatement(sql);
            //给参数传值
            ment.setObject(1, "%" + name + "%");
            ment.setObject(2, from);
            ment.setObject(3, pageSixe);
            resultSet = ment.executeQuery();
            if (resultSet != null) {
                while (resultSet.next()) {
                    Vivoproduct vivoej = new Vivoproduct();
                    vivoej.setId(resultSet.getString(1));
                    vivoej.setEid(resultSet.getInt(2));
                    vivoej.setYid(resultSet.getInt(3));
                    vivoej.setEtype(resultSet.getString(4));
                    vivoej.setDescs(resultSet.getString(5));
                    vivoej.setImg(resultSet.getString(6));
                    vivoej.setImage(resultSet.getDouble(7));
                    vivoej.setPv(resultSet.getInt(8));
                    vivoej.setKc(resultSet.getInt(9));
                    vivoej.setStatus(resultSet.getInt(10));
                    vivoej.setAdd_time(resultSet.getString(11));
                    list.add(vivoej);
                }
            }
            return list;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(conn, ment, resultSet);
        }
    }
}

